package cn.iocoder.yudao.module.promotion.api.combination;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationProductDTO;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationSkuPriceDTO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationSkuPriceDO;
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@Service
public class CombinationActivityApiImpl implements CombinationActivityApi {
    @Resource
    private CombinationActivityService activityService;

    @Override
    public List<CombinationSkuPriceDTO> selectMinPriceSkuListBySpuId(List<Long> spuIds) {
        final List<CombinationSkuPriceDO> productDOList = activityService.selectMinPriceSkuListBySpuId(spuIds);
        return BeanUtils.toBean(productDOList, CombinationSkuPriceDTO.class);
    }

    @Override
    public List<CombinationProductDTO> getCombinationProductBySkuIds(Collection<Long> skuIds) {
        final List<CombinationProductDO> combinationProductBySkuIds = activityService.getCombinationProductBySkuIds(skuIds);
        return BeanUtils.toBean(combinationProductBySkuIds, CombinationProductDTO.class);
    }

    @Override
    public List<CombinationProductDTO> getCombinationProductBySpuIdV2(Long spuId) {
        final List<CombinationProductDO> list = activityService.getCombinationProductBySpuIdV2(spuId);
        return BeanUtils.toBean(list, CombinationProductDTO.class);
    }

}
